<template>
  <div>
    <C1 ref="C1"/>
    <C2 ref="C2"/>
    <!-- 下单成功支付框 -->
    <PayBox ref="payBox" :noBackBtn="true"/>

    <Card class="marginB10">
      <div class="overflowH f_14 TJ_big">
        <div class="TJ_title f_bold f_16">
          软件信息
          <span class="cRed">*</span>
        </div>
        <div class="TJ_box">
          <div class="cRed marginB20 visHidden">x</div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">软件全称：</div>
            <div class="overflowH">
              <Input
                placeholder="请输入软件全称"
                size="large"
                v-model="software_name"
                ref="software_name"
                clearable
                class="marginR10 SQ_One_R"
              />
              <span class="cCCC">  参考：品牌+产品用途+功能，需以软件、系统、平台为名称结尾</span>
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">软件简称：</div>
            <div class="overflowH">
              <Input
                placeholder="请输入软件简称（选填）"
                size="large"
                v-model="software_short_name"
                ref="software_short_name"
                clearable
                class="marginR10 SQ_One_R"
              />
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">版本号：</div>
            <div class="overflowH">
              <Input
                placeholder="请输入版本号"
                size="large"
                v-model="version_no"
                ref="version_no"
                clearable
                class="marginR10 SQ_One_R"
              />
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">开发完成日期：</div>
            <div class="overflowH">
              <DatePicker
                v-model="finish_time"
                type="date"
                class="marginR10 SQ_One_R"
                placeholder="请选择开发完成日期"
                style="width: 200px"
                size="large"
                :editable="false"
                :clearable="false"
                :options="optMax"
              ></DatePicker>
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">发表状态：</div>
            <div class="overflowH lineH30">
              <RadioGroup v-model="publish_state" size="large">
                <Radio :label="0">未发表</Radio>
                <Radio :label="1">已发表</Radio>
              </RadioGroup>
            </div>
          </div>
          <div class="marginB20 clearBoth" v-show="publish_state==1">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">首次发表日期：</div>
            <div class="overflowH">
              <DatePicker
                v-model="publish_time"
                type="date"
                class="marginR10 SQ_One_R"
                placeholder="请选择首次发表日期"
                style="width: 200px"
                size="large"
                :editable="false"
                :clearable="false"
                :options="optMax"
              ></DatePicker>
            </div>
          </div>
          <div class="marginB20 clearBoth" v-show="publish_state==1">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">首次发表地点：</div>
            <div class="overflowH lineH34">
              国家：
              <span class="cBlue f_bold marginR20">{{publish_country.text}}</span>
              城市：
              <Input
                placeholder="请输入城市"
                size="large"
                v-model="publish_city"
                ref="publish_city"
                clearable
                class="marginR5"
                style="width:150px"
              />
            </div>
          </div>
        </div>
      </div>
    </Card>

    <Card class="marginB10">
      <div class="overflowH f_14 TJ_big">
        <div class="TJ_title f_bold f_16">
          权利说明
          <span class="cRed">*</span>
        </div>
        <div class="TJ_box">
          <div class="cRed marginB20 visHidden">x</div>
          <div class="marginB10 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">软件作品说明：</div>
            <div class="overflowH lineH34 cBlue f_bold">原创</div>
          </div>
          <div class="marginB10 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">开发方式：</div>
            <div class="overflowH lineH34 cBlue f_bold">独立开发</div>
          </div>
          <div class="marginB10 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">权利取得方式：</div>
            <div class="overflowH lineH34 cBlue f_bold">原始取得</div>
          </div>
          <div class="marginB10 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">权利范围：</div>
            <div class="overflowH lineH34 cBlue f_bold">全部 </div>
          </div>
        </div>
      </div>
    </Card>

    <Card class="marginB10">
      <div class="overflowH f_14 TJ_big">
        <div class="TJ_title f_bold f_16">
          技术特点
          <span class="cRed">*</span>
        </div>
        <div class="TJ_box">
          <div class="cRed marginB20 visHidden">x</div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">编程语言：</div>
            <div class="overflowH">
              <Input
                placeholder="请输入编程语言"
                size="large"
                v-model="program_lang"
                ref="program_lang"
                clearable
                class="marginR10 SQ_One_R"
              />
              <span class="cCCC">指编写登记软件的编程语言，如：VC6.0,VB6.0</span>
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">源程序量：</div>
            <div class="overflowH">
              <Input
                placeholder="请输入源程序量"
                size="large"
                v-model="code_row_num"
                ref="code_row_num"
                clearable
                class="marginR10 SQ_One_R"
              />
              <span class="cCCC">指登记软件的源程序的总行数或者总条数</span>
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">硬件环境：</div>
            <div class="overflowH">
              <Input
                type="textarea"
                placeholder="指开发和运行登记软件的计算机硬件和专用设备"
                clearable
                v-model="hardware_env"
                ref="hardware_env"
                style="width:600px;"
                :rows="4"
              />
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">软件环境：</div>
            <div class="overflowH">
              <Input
                type="textarea"
                placeholder="指开发和运行登记软件的操作系统、支持软件的名称及版本号"
                clearable
                v-model="software_env"
                ref="software_env"
                style="width:600px;"
                :rows="4"
              />
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L  c333 f_14 w150 pullLeft">主要功能和<br/>技术特点:</div>
            <div class="overflowH">
              <Input
                type="textarea"
                placeholder="简短明确阐述软件的创作目的、主要功能、用途和技术特点。说明字数限于350个汉字。"
                clearable
                v-model="main_func"
                ref="main_func"
                style="width:600px;"
                :rows="4"
              />
            </div>
          </div>

        </div>
      </div>
    </Card>

    <Card class="marginB10">
      <div class="overflowH f_14 TJ_big">
        <div class="TJ_title f_bold f_16">
          鉴别材料
          <span class="cRed">*</span>
        </div>
        <div class="TJ_box">
          <div class="cRed marginB20 visHidden">x</div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft cBlue f_bold">一般交存：</div>
            <div class="overflowH lineH34 cBlue f_bold">一种文档</div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">上传源程序：</div>
            <div class="overflowH">
              <div class="relative overflowH pullLeft marginR10" style="width:95px;">
                <Button type="primary">上传 Word</Button>
                <input
                  type="file" ref="fA"
                  class="InputFileBox "
                  accept=".docx,.doc"
                  @change="wordUp($event,1)"
                />
              </div>
              <div class="pullLeft marginR20 relative textLink" style="top:-6px;" v-show="$app.judgeData(code_word_file_path.file_url)" @click="$app.openWindow(code_word_file_path.file_url)" >
                <i class="iconfont f_24 cBlue marginR5 relative" style="top:4px;"  :class="$app.judgeData(code_word_file_path) && $app.fileIcon(code_word_file_path)"></i>
                {{codeText}}
              </div>
              <div class="clearBoth  c999 paddingT10">
                 	限word文档，按前、 后各连续 30 页, 共60 页(不足 60 页全部提交）；<br/>
                  每页不少于 50 行(结束页除外),页眉上是产品名称及版本号及右上角标注页号 1-60；<br/>
                  名称和版本号，应当与以上所填写的信息中相应内容完全一致。
              </div>
            </div>
          </div>
          <div class="marginB20 clearBoth">
            <div class="SQ_One_L lineH34 c333 f_14 w150 pullLeft">上传说明文档：</div>
            <div class="overflowH">
              <div class="relative overflowH pullLeft marginR10" style="width:95px;">
                <Button type="primary">上传 Word</Button>
                <input
                  type="file" ref="fB"
                  class="InputFileBox "
                  accept=".docx,.doc"
                  @change="wordUp($event,2)"
                />
              </div>
              <div class="pullLeft marginR20 relative textLink" style="top:-6px;" v-show="$app.judgeData(desc_word_file_path.file_url)" @click="$app.openWindow(desc_word_file_path.file_url)" >
                <i class="iconfont f_24 cBlue marginR5 relative" style="top:4px;"  :class="$app.judgeData(desc_word_file_path) && $app.fileIcon(desc_word_file_path)"></i>
                {{descText}}
              </div>
              <div class="clearBoth  c999 paddingT10">
                 	限word文档，按前、后各连续 30页, 共 60 页(不足 60 页全部提交)；<br/>
                  每页不少于 30 行（有图除外）, 页眉上是产品名称及版本号及右上角标注页号 1-60；<br/>
                  名称和版本号，应当与以上所填写的信息中相应内容完全一致。 
              </div>
            </div>
          </div>
        </div>
      </div>
    </Card>
    <template v-if="$app.judgeData(order_id)">
      <Button type="primary" size="large" class="marginR10" ghost @click="backOrSee">
        <Icon type="md-arrow-round-back" size="18" class="relative"  />
        返回
      </Button>
    </template>
    
    <template v-if="$app.judgeData(bz_id)">
      <Button type="primary" size="large" @click="bigGo">提交补正</Button>
    </template>
    <template v-else>
      <Button type="primary" size="large" @click="bigGo">{{$app.judgeData(order_id)?'确认修改':'提 交'}}</Button>
    </template>
  </div>
</template>


<script>
import C1 from "./common/c1";
import C2 from "./common/c2";
import PayBox from "@$@/_service/payBox";
export default {
  name: "copyrightDoRJ",
  components: { C1, C2,PayBox },
  data() {
    let {
      $route:{
        query:{
          order_id,
          id:bz_id
        }
      }
    }=this;

    let data = {
      bz_id,//补正时候的id
      order_id:($app.judgeData(order_id)?order_id:''),//订单ID
      software_name: "",
      software_short_name:'',
      version_no:'',//版本号
      finish_time:'',//开发完成
      publish_state:0,//发表状态,1已发表,0未发表
      publish_time:'',//首次发布日期
      publish_country:{//首次发表地点 国家
        type:'cn',
        text:'中国'
      },
      publish_city:'',//首次发表地点 城市



      
      program_lang:'',//编程语言
      code_row_num:'',//源程序量
      hardware_env:'',//硬件环境描述
      software_env:'',//软件环境
      main_func:'',//主要功能


      


      //上传源程序
      code_word_file_path:{
        file_url:'',//前端展示路径
        file_path:''//上传给后台的路径
      },
      codeText:'',

      desc_word_file_path:{
        file_url:'',//前端展示路径
        file_path:''//上传给后台的路径
      },
      descText:'',




      // 日期插件
      optMax: {
        disabledDate(date) {
          let out = date && date.valueOf() > Date.now();
          return out;
        }
      },
      orderInfo:{}//专利详情 修改订单时用
    };
    return data;
  },
  created() {
    let {
      order_id
    }=this;
    if($app.judgeData(order_id)){
      //版权详情
      $ajax.copyrightII(order_id,resData=>{
        this.orderInfo=resData;
        //全局赋值
        $app.wetRK(this);
      });
    }
  },

  methods: {
    //上传wrod
    wordUp(e,num){
      let file = e.target.files[0];//选中的文件
      //格式判断
      $app.suffix.word(e,file,false,()=>{
        //1营业执照，2专利文件or委托书，3身份证,4外观设计图片,5外观说明文件,6软著文件,7美术著作文件,8商标文件 
        $ajax.upOther(file,6,(resData,file_name)=>{
          if(num==1){//上传源程序
            this.code_word_file_path=resData;
            this.codeText=file_name;
          }else{//上传说明文档
            this.desc_word_file_path=resData;
            this.descText=file_name;
          }

          this.$refs['fA'].value='';
          this.$refs['fB'].value='';
          
        },()=>{
          this.$refs['fA'].value='';
          this.$refs['fB'].value='';
        });
      });
      
    },


    //准备就绪，提交
    bigGo(){
      let that=this;
      let {bz_id,order_id}=that;
      

      //C1 基础信息取值
      let {
        goods_id,//商品ID 路由取值
        people_type,people_country,
        addObj:{
          people_province,people_city
        },people_name,cert_type,cert_number,
        cert_file_path:{
          file_path:cert_file_path
        }
      }=that.$refs['C1'];

      //总共9个
      //console.log('C1 = ',goods_id,people_type,people_country,people_province,people_city,people_name,cert_type,cert_number,cert_file_path);



      //C2 联系方式
      let {
        reg_people_name,
        reg_people_contact,
        reg_people_phone,
        reg_people_tel,
        reg_people_email,
        reg_people_address
      }=that.$refs['C2'];

      //总共6个
      //console.log('C2 = ',reg_people_name,reg_people_contact,reg_people_phone,reg_people_tel,reg_people_email,reg_people_address);


      let {
        software_name,
        software_short_name,
        version_no,
        finish_time,
        publish_state,//0未发表,1已发表,
        publish_time,
        publish_country:{
          type:publish_country
        },
        publish_city,
        program_lang,//编程语言
        code_row_num,//源程序量
        hardware_env,//硬件环境描述
        software_env,//软件环境
        main_func,
        code_word_file_path:{
          file_path:code_word_file_path
        },
        desc_word_file_path:{
          file_path:desc_word_file_path
        }
      }=this;

      //创作完成时间，时间戳转换
      let fTime=(finish_time.valueOf())/1000;
      ($app.judgeData(fTime))&&(finish_time=$app.formatTime(2,fTime));


      if(publish_state==1){
        let pTime=(publish_time.valueOf())/1000;
        ($app.judgeData(pTime))&&(publish_time=$app.formatTime(2,pTime));
      }else{
        publish_time='';
        publish_country='';
        publish_city='';
      }

      //总共15个
      //console.log('本页参数 = ',software_name,software_short_name,version_no,finish_time,publish_state,publish_time,publish_country,publish_city,program_lang,code_row_num,hardware_env,software_env,main_func,code_word_file_path,desc_word_file_path)

      let obj={
        bz_id,
        order_id,
        //C1 9个值
        goods_id,people_type,people_country,people_province,people_city,people_name,cert_type,cert_number,cert_file_path,

        //C2 6个值
        reg_people_name,reg_people_contact,reg_people_phone,reg_people_tel,reg_people_email,reg_people_address,

        //本页面 15个值
        software_name,software_short_name,version_no,finish_time,publish_state,publish_time,publish_country,publish_city,program_lang,code_row_num,hardware_env,software_env,main_func,code_word_file_path,desc_word_file_path,


        //以下6个位固定值
        works_desc:'原创',
        dev_mode:1,
        get_way:'原始取得',
        right_rang:'全部',
        ybjc:1,
        type_doc:1
      };


      console.log(obj);

      //基础信息+联系方式，正则判断，其中有一个为false，就会断开不往下走。
      $app.banQbase(that, obj, () => {
        //软件信息 判断
        if (!$app.judgeData($app.delSpace(obj.software_name))) {
          that.$Message.error({ content: "软件全称，不能为空" });
          that.$refs["software_name"].focus();
          that.software_name = "";
          return;
        }
        if (!$app.judgeData($app.delSpace(obj.version_no))) {
          that.$Message.error({ content: "软件版本号，不能为空" });
          that.$refs["version_no"].focus();
          that.version_no = "";
          return;
        }

        if (!$app.judgeData($app.delSpace(obj.finish_time))) {
          $app.alert("软件开发完成日期，不能为空");
          return;
        }

        if(obj.publish_state==1){//0未发表 1已发表
          if (!$app.judgeData($app.delSpace(obj.publish_time))) {
            $app.alert("软件首次发表日期，不能为空");
            return;
          }

          if (!$app.judgeData($app.delSpace(obj.publish_city))) {
            that.$Message.error({ content: "软件首次发表城市，不能为空" });
            that.$refs["publish_city"].focus();
            that.publish_city = "";
            return;
          }
        }


        //技术特点
        if (!$app.judgeData($app.delSpace(obj.program_lang))) {
          that.$Message.error({ content: "编程语言，不能为空" });
          that.$refs["program_lang"].focus();
          that.program_lang = "";
          return;
        }
        if (!$app.judgeData($app.delSpace(obj.code_row_num))) {
          that.$Message.error({ content: "源程序量，不能为空" });
          that.$refs["code_row_num"].focus();
          that.code_row_num = "";
          return;
        }

        if (!$app.judgeData($app.delSpace(obj.hardware_env))) {
          that.$Message.error({ content: "硬件环境，不能为空" });
          that.$refs["hardware_env"].focus();
          that.hardware_env = "";
          return;
        }

        if (!$app.judgeData($app.delSpace(obj.software_env))) {
          that.$Message.error({ content: "软件环境，不能为空" });
          that.$refs["software_env"].focus();
          that.software_env = "";
          return;
        }

        if (!$app.judgeData($app.delSpace(obj.main_func))) {
          that.$Message.error({ content: "主要功能和技术特点，不能为空" });
          that.$refs["main_func"].focus();
          that.main_func = "";
          return;
        }


        //鉴别材料
        if (!$app.judgeData($app.delSpace(obj.code_word_file_path))) {
          $app.alert("请上传源程序");
          return;
        }
        if (!$app.judgeData($app.delSpace(obj.desc_word_file_path))) {
          $app.alert("请上传说明文档");
          return;
        }

        

        $ajax.copyrightRJ(obj,resData=>{
          if($app.judgeData(order_id)||$app.judgeData(bz_id)){//有值 修改订单
            $app.toast(($app.judgeData(bz_id)?'提交成功':'订单修改成功'),true);
            $app.backOrSee();
          }else{//没值 首次提交
            $app.payBoxShow(that,resData.order_id);//调起支付框
          }
        });
      });

      

    },
    //返回上一级
    backOrSee(){
      $app.backOrSee();
    }
  },
  mounted() {
    //
  }
};
</script>

